<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%>
<c:set var="path" value="..${ctx}/common/table"/>


	<SCRIPT type="text/javascript">
		<!--
		var setting = {
			check: {
				enable: true,
				chkboxType: {"Y":"", "N":""}
			},
			view: {
				dblClickExpand: false
			},
			data: {
				simpleData: {
					enable: true
				}
			},
			callback: {
				beforeClick: beforeClick,
				onCheck: onCheck
			}
		};

		var zNodes =[
			{id:1, pId:0, name:"北京",checked:true},
			{id:2, pId:0, name:"天津"},
			{id:3, pId:0, name:"上海"},
			{id:6, pId:0, name:"重庆"},
			{id:4, pId:0, name:"河北省", open:true, nocheck:true},
			{id:41, pId:4, name:"石家庄"},
			{id:42, pId:4, name:"保定"},
			{id:43, pId:4, name:"邯郸"},
			{id:44, pId:4, name:"承德"},
			{id:5, pId:0, name:"广东省", open:true, nocheck:true},
			{id:51, pId:5, name:"广州"},
			{id:52, pId:5, name:"深圳"},
			{id:53, pId:5, name:"东莞"},
			{id:54, pId:5, name:"佛山"},
			{id:6, pId:0, name:"福建省", open:true, nocheck:true},
			{id:61, pId:6, name:"福州"},
			{id:62, pId:6, name:"厦门"},
			{id:63, pId:6, name:"泉州"},
			{id:64, pId:6, name:"三明"}
		 ];

		function beforeClick(treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo");
			zTree.checkNode(treeNode, !treeNode.checked, null, true);
			return false;
		}
		
		function onCheck(e, treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
			nodes = zTree.getCheckedNodes(true),
			v = "";
			for (var i=0, l=nodes.length; i<l; i++) {
				v += nodes[i].name + ",";
			}
			if (v.length > 0 ) v = v.substring(0, v.length-1);
			var cityObj = $("#citySel");
			cityObj.attr("value", v);
		}

		function showMenu() {
			var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
			var child = treeObj.getNodesByParam("id","2",null);
			var node = treeObj.getNodeByTId("3");
			treeObj.checkNode(child[0],true,true);
			treeObj.checkNode(node,true,true);
			var cityObj = $("#citySel");
			var cityOffset = $("#citySel").position();
			$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");
			$("body").bind("mousedown", onBodyDown);
		}
		function hideMenu() {
			$("#menuContent").fadeOut("fast");
			$("body").unbind("mousedown", onBodyDown);
		}
		function onBodyDown(event) {
			if (!(event.target.id == "menuBtn" || event.target.id == "citySel" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
				hideMenu();
			}
		}

		$(document).ready(function(){
			//alert(zNodes[2].name);
			$.fn.zTree.init($("#treeDemo"), setting, zNodes);
		});
		//-->
	</SCRIPT>


<div class="pageContent">
	<form method="post" action="${path}/ajaxupdate.html" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
	<input type="hidden" name="tableName" value="bs_user" />
	<input type="hidden" name="table.id.name" value="userID" />
	<input type="hidden" name="tableAction" value="save" />
	<input type="hidden" name="jspPageName" value="${path}/tablenamepaginglist.html?tableName=bs_user&jspPageName=base/user/list" />
		<div class="pageFormContent" layoutH="56">
			<fieldset>
				<dl>
					<dt>用户编号：</dt>
					<dd><input name="bs_user.userID" type="text" size="30" value="${data.userID}" readonly="readonly"/></dd>
				</dl>
				<dl>
					<dt>用户名：</dt>
					<dd><input name="bs_user.userName" type="text" size="30" value="${data.userName}" class="required" /></dd>
				</dl>
				<dl>
					<dt>用户姓名：</dt>
					<dd><input name="bs_user.realName" type="text" size="30" value="${data.realName}" /></dd>
				</dl>
				<dl>
					<dt>上次登录时间：</dt>
					<dd><input name="bs_user.lastLoginTime" type="text" size="30" class="date" readonly="true" value="${data.lastLoginTime}" />
						<a class="inputDateButton" href="javascript:;">选择</a>
					</dd>
				</dl>
				<dl>
					<dt>工作组：</dt>
					<dd><input id="citySel" name="bs_user.groups" type="text" size="30" value="${data.groups}" />
						<a class="btnLook" id="menuBtn" href="#" onclick="showMenu(); return false;">查找带回</a>
					</dd>
				</dl>
				<dl>
					<dt>角色：</dt>
					<dd><input name="bs_user.roles" type="text" size="30" value="${data.roles}" /></dd>
				</dl>
			</fieldset>
		</div>
		<div class="formBar">
			<ul>
				<!--<li><a class="buttonActive" href="javascript:;"><span>保存</span></a></li>-->
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit" >保存</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">关闭</button></div></div>
				</li>
			</ul>
		</div>
	</form>
</div>

<div id="menuContent" class="menuContent" style="display:none; position: absolute;">
	<ul id="treeDemo" class="ztree" style="margin-top:0; width:180px; height: 300px;"></ul>
</div>

<script type="text/javascript">
/**
 * dialog上的表单提交回调函数
 * 服务器转回navTabId，可以重新载入指定的navTab. statusCode=DWZ.statusCode.ok表示操作成功, 自动关闭当前dialog
 *
 * form提交后返回json数据结构,json格式和navTabAjaxDone一致
 */

function dialogAjaxDone(json){
	DWZ.ajaxDone(json);
	if (json.statusCode == DWZ.statusCode.ok){
		// alert(json.callbackType);
		if(json.callbackType){
			navTab.reload("${path}/tablenamepaginglist.html?tableName=bs_user&jspPageName=base/user/list");//刷新
			setTimeout(function(){$.pdialog.closeCurrent();}, 100);
		}
	}
}
</script>
